using cuberga.GA.Permutation;
using System.Collections;
using System.Collections.Generic;
using System;

namespace cuberga.GA
{
    public class PermutationPopulation
    {
        //private ArrayList _list = new ArrayList();
        private List<Genotype> _list;

        public PermutationPopulation()
        {
            _list = new List<Genotype>();
        }

        public void Initialize(int populationSize, int genotypeSize)
        {
            for (int i = 0; i < populationSize; i++)
            {
                Genotype gen = new PermutationGenotype(genotypeSize);
                Add(gen);

                // Debug start
                string debug_log = "";
                int[] z = (int[])gen.ToStructure();
                for (int cell = 0; cell < z.Length; cell++)
                    debug_log = string.Format("{0}{1},", debug_log, z[cell]);
                debug_log = string.Format("{0}\n", debug_log);
                Console.WriteLine(debug_log);
                // Debug finish
            }


        }

        public Genotype this[int iIndex]
        {
            get { return _list[iIndex]; }
            set { _list[iIndex] = value; }
        }

        public void Add(Genotype newData)
        {
            _list.Add(newData);
        }

        public IEnumerator<Genotype> GetEnumerator()
        {
            return _list.GetEnumerator();
        }

    }
}
